<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@include file="/common/mytags.jsp" %>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>管理员列表</title>
    <!-- load css -->
    <link rel="stylesheet" type="text/css" href="<%=basePath%>common/frame/layui/css/layui.css" media="all">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>common/css/gobal.css" media="all">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>backstage/css/common.css" media="all">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>backstage/css/flink.css" media="all">
</head>
<body>
<div class="layui-fluid larry-wrapper">
    <blockquote class="layui-elem-quote larry-btn">
    
    <div class="layui-input-inline">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-block">
        <input style="width: 130px;" type="text" name="userPhone" id="userPhone" class="layui-input" >
        </div>
    </div>
     <div class="layui-input-inline">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
        <input style="width: 130px;" type="text" name="userName" id="userName" class="layui-input" >
        </div>
    </div>



        <a class="layui-btn " data-type="getSelect" id="getSelect" > 查询  </a>

        <authority:auto target="CREATE_USER" >
            <a class="layui-btn  layui-btn-normal" style="float: right;" id="add_manager" lay-event="add">添加管理员</a>
        </authority:auto>
    </blockquote>
    
    <div class="flinkTable">
        <table class="layui-table"   style="  "  id="bannerPage" lay-filter="bannerPage"></table>
    </div>


</div>
<script type="text/html" id="merchantBar">
    <authority:auto target="USER_ROLE_INNER" >
        <a class="layui-btn layui-btn-xs  " lay-event="user_role">分配角色</a>&nbsp;
    </authority:auto>
</script>



<script type="text/javascript" src="<%=basePath%>common/frame/layui/layui.js"></script>

<script>
    layui.config({
        base: "<%=basePath%>common/larrylib/",
        version: '201808031'
    }).use(["layer", "form", "table", "jquery", "laydate", "upload"], function () {
        var $ = layui.jquery;
        var e = layui.$, t = layui.layer, i = layui.form, l = layui.table;
        var width = $(document).width();
        var height = $(document).height();


      var a = l.render({
            elem: "#bannerPage",
            width: width,
            height: 'full-140',
            id: 'mytable',
            size: 'lg',
            cols: [[
				{checkbox:true, type:'checkbox',fixed: 'left',width: width * 0.05},
                {field: 'name', title: '用户名', align: "center", width: width * 0.25},
                {field: 'phone', title: '手机号', align: "center", width: width * 0.25},
                {field: 'extend', title: '角色', align: "center", width: width * 0.1},
                {title: "常用操作", width: width * 0.2, align: "center", toolbar: "#merchantBar", fixed: "right"}
            ]],
            request: {
            	  pageName: 'pageNumber',
            	  limitName: 'pageSize'
            	},   
            response: {
                statusName: 'state' //数据状态的字段名称，默认：code
                , statusCode: 200 //成功的状态码，默认：0
                , msgName: 'message' //状态信息的字段名称，默认：msg
                , countName: 'totalRow' //数据总数的字段名称，默认：count
                , dataName: 'data' //数据列表的字段名称，默认：data
            },
            url: "<%=basePath%>user/list",
            page: true,
            limit: 10,
            even: true
        });

        l.on("tool(bannerPage)", function (e) {
            var i = e.data;

            if (e.event == "user_role") {
                var e = layui.layer.open({
                    title: "分配 "+i.name+"角色",
                    type: 2,
                    move: false,
                    anim: 1,
                    skin: "larry-green",
                    offset: '80px',
                   /* area: [width / 1.73 + "px", height*0.7 + "px"],*/
                    area: [width / 2.6 + "px", height*0.8 + "px"],
                    content: "<%=basePath%>user/role/page?userId="+i.id
                });
            }

        });
        


        e("#add_manager").on("click", function () {
            var e = layui.layer.open({
                title: "添加管理员",
                type: 2,
                move: false,
                anim: 1,
                skin: "larry-green",
                offset: '80px',
                area: [width / 2.5 + "px", height*0.5 + "px"],
                content: "<%=basePath%>user/toAddManager"
            });
        });
        
        e(".larry-btn a.layui-btn").on("click", function () {
            var t = e(this).data("type");
            r[t] ? r[t].call(this) : "";
        });

        var r = {
            getSelect: function () {
                var i = t.msg("查询中，请稍候...", {icon: 16, time: false, shade: 0});
                var userPhone = e("#userPhone").val();
                var userName = e("#userName").val();
                l.reload('mytable', {
                    where: {
                        userPhone:userPhone,
                        userName:userName,
                    },method:'post',
                    height: 'full-140',method:'post'
                });
                t.close(i);
            }

        };
       

    });

</script>


</body>
</html>